package com.cbd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cbd.dto.AdminDto;
import com.cbd.entity.UserEntity;
import com.cbd.mapper.SuperAdminMapper;
import com.cbd.mapper.UserMapper;
import com.cbd.service.ISuperAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: xue
 * @Date: 2024/11/25 11:22
 * @Description:超级管理员业务实现类
 */
@Service
@Slf4j
public class SuperAdminServiceImpl implements ISuperAdminService {
    @Resource
    private SuperAdminMapper superAdminMapper;
    @Resource
    private UserMapper userMapper;
    @Override
    public boolean login(AdminDto adminDto) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("username", adminDto.getUsername());
        queryWrapper.eq("password", adminDto.getPassword());
        UserEntity user = userMapper.selectOne(queryWrapper);
        if (user == null) {
            return false;
        }
        return true;
    }
    @Override
    public String addAdmin(String username, String roleName) {
        String result = superAdminMapper.addAdmin(username, roleName);
        return result;
    }
}
